package com.cn.kabalifeuser.ui.my.activity;

import com.cn.kabalifeuser.api.Api;
import com.cn.kabalifeuser.base.BasePresenter;
import com.cn.kabalifeuser.callback.CacheCallBack;
import com.cn.kabalifeuser.config.Constants;
import com.cn.kabalifeuser.ui.my.bean.MyUserInfoBean;
import com.cn.kabalifeuser.ui.my.bean.ReportFormListBean;
import com.cn.kabalifeuser.utils.LoggerUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * Created by 晓林 on 2020/9/4.
 * function:
 */
public class ReportFormPresenter extends BasePresenter<ReportFormView> {

    public void onReportFormData(String token) {
        OkGo.<ReportFormListBean>post(Api.API_USER_FORM)
                .headers("token", token)
                .execute(new CacheCallBack<ReportFormListBean>() {
                    @Override
                    public void onSuccess(Response<ReportFormListBean> response) {
                        super.onSuccess(response);
                        LoggerUtils.e("报表" + response.body());
                        if (isViewAttached())
                            if (response.body().getCode() == Constants.HTTP_SUCCESS)
                                getView().onReportFormSuccess(response.body());
                            else if (response.body().getCode() == Constants.HTTP_AGAIN_LOGIN)
                                getView().onReLoggedIn(response.body().getMsg());
                            else
                                getView().onError(response.body().getMsg());
                    }
                });
    }

}
